'''
Created on 23 Nov 2009

@author: ralf
'''

import imp
from google.protobuf.descriptor import Descriptor
from exceptions import Exception

global counter
counter = 0

def load_descriptors_module(module):
    descriptors = []
    for key, value in module.__dict__.items():
        if type(value) == Descriptor:
            descriptors.append(value)
    return descriptors
    
def load_descriptors(path):
    global counter
    module = imp.load_source("protobufmessagemodule%d" % counter, path)
    return load_descriptors_module(module)

